Search in sources :

Example 1 with BuiltInPlaceholder

use of com.loohp.interactivechat.objectholders.BuiltInPlaceholder in project InteractiveChat by LOOHP.

the class InteractiveChatVelocity method onReceive.

@Subscribe
public void onReceive(PluginMessageEvent event) {
    if (!event.getIdentifier().getId().equals("interchat:main")) {
        return;
    }
    ChannelMessageSource source = event.getSource();
    if (!(source instanceof ServerConnection)) {
        return;
    }
    event.setResult(ForwardResult.handled());
    RegisteredServer server = ((ServerConnection) source).getServer();
    String senderServer = server.getServerInfo().getName();
    byte[] packet = Arrays.copyOf(event.getData(), event.getData().length);
    ByteArrayDataInput in = ByteStreams.newDataInput(packet);
    int packetNumber = in.readInt();
    int packetId = in.readShort();
    if (!Registry.PROXY_PASSTHROUGH_RELAY_PACKETS.contains(packetId)) {
        boolean isEnding = in.readBoolean();
        byte[] data = new byte[packet.length - 7];
        in.readFully(data);
        byte[] chain = incomming.remove(packetNumber);
        if (chain != null) {
            ByteBuffer buff = ByteBuffer.allocate(chain.length + data.length);
            buff.put(chain);
            buff.put(data);
            data = buff.array();
        }
        if (!isEnding) {
            incomming.put(packetNumber, data);
            return;
        }
        byte[] finalData = data;
        pluginMessageHandlingExecutor.submit(() -> {
            try {
                ByteArrayDataInput input = ByteStreams.newDataInput(finalData);
                switch(packetId) {
                    case 0x07:
                        int cooldownType = input.readByte();
                        switch(cooldownType) {
                            case 0:
                                UUID uuid = DataTypeIO.readUUID(input);
                                long time = input.readLong();
                                playerCooldownManager.setPlayerUniversalLastTimestamp(uuid, time);
                                break;
                            case 1:
                                uuid = DataTypeIO.readUUID(input);
                                UUID internalId = DataTypeIO.readUUID(input);
                                time = input.readLong();
                                playerCooldownManager.setPlayerPlaceholderLastTimestamp(uuid, internalId, time);
                                break;
                        }
                        for (RegisteredServer eachServer : getServer().getAllServers()) {
                            if (!eachServer.getServerInfo().getName().equals(senderServer) && eachServer.getPlayersConnected().size() > 0) {
                                eachServer.sendPluginMessage(ICChannelIdentifier.INSTANCE, finalData);
                                pluginMessagesCounter.incrementAndGet();
                            }
                        }
                        break;
                    case 0x08:
                        UUID messageId = DataTypeIO.readUUID(input);
                        String component = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        messageForwardingHandler.receivedProcessedMessage(messageId, component);
                        break;
                    case 0x09:
                        loadConfig();
                        break;
                    case 0x0B:
                        int id = input.readInt();
                        boolean permissionValue = input.readBoolean();
                        permissionChecks.put(id, permissionValue);
                        break;
                    case 0x0C:
                        int size1 = input.readInt();
                        List<ICPlaceholder> list = new ArrayList<>(size1);
                        for (int i = 0; i < size1; i++) {
                            boolean isBuiltIn = input.readBoolean();
                            if (isBuiltIn) {
                                String keyword = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String name = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String description = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String permission = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                long cooldown = input.readLong();
                                list.add(new BuiltInPlaceholder(Pattern.compile(keyword), name, description, permission, cooldown));
                            } else {
                                int customNo = input.readInt();
                                ParsePlayer parseplayer = ParsePlayer.fromOrder(input.readByte());
                                String placeholder = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                boolean parseKeyword = input.readBoolean();
                                long cooldown = input.readLong();
                                boolean hoverEnabled = input.readBoolean();
                                String hoverText = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                boolean clickEnabled = input.readBoolean();
                                String clickAction = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String clickValue = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                boolean replaceEnabled = input.readBoolean();
                                String replaceText = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String name = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String description = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                list.add(new CustomPlaceholder(customNo, parseplayer, Pattern.compile(placeholder), parseKeyword, cooldown, new CustomPlaceholderHoverEvent(hoverEnabled, hoverText), new CustomPlaceholderClickEvent(clickEnabled, clickEnabled ? ClickEventAction.valueOf(clickAction) : null, clickValue), new CustomPlaceholderReplaceText(replaceEnabled, replaceText), name, description));
                            }
                        }
                        placeholderList.put(server.getServerInfo().getName(), list);
                        playerCooldownManager.reloadPlaceholders(placeholderList.values().stream().flatMap(each -> each.stream()).distinct().collect(Collectors.toList()));
                        PluginMessageSendingVelocity.forwardPlaceholderList(list, server);
                        break;
                    case 0x0D:
                        UUID uuid2 = DataTypeIO.readUUID(input);
                        PluginMessageSendingVelocity.reloadPlayerData(uuid2, server);
                        break;
                    case 0x10:
                        UUID requestUUID = DataTypeIO.readUUID(input);
                        int requestType = input.readByte();
                        switch(requestType) {
                            case 0:
                                PluginMessageSendingVelocity.respondPlayerListRequest(requestUUID, server);
                                break;
                            default:
                                break;
                        }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    } else {
        pluginMessageHandlingExecutor.submit(() -> {
            for (RegisteredServer eachServer : getServer().getAllServers()) {
                if (!eachServer.getServerInfo().getName().equals(senderServer) && eachServer.getPlayersConnected().size() > 0) {
                    eachServer.sendPluginMessage(ICChannelIdentifier.INSTANCE, event.getData());
                    pluginMessagesCounter.incrementAndGet();
                }
            }
        });
    }
}
Also used : Arrays(java.util.Arrays) Inject(com.google.inject.Inject) ConnectedPlayer(com.velocitypowered.proxy.connection.client.ConnectedPlayer) Random(java.util.Random) ProxyShutdownEvent(com.velocitypowered.api.event.proxy.ProxyShutdownEvent) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) ByteBuffer(java.nio.ByteBuffer) Matcher(java.util.regex.Matcher) ChannelPromise(io.netty.channel.ChannelPromise) PluginMessageEvent(com.velocitypowered.api.event.connection.PluginMessageEvent) Player(com.velocitypowered.api.proxy.Player) Map(java.util.Map) ProxyInitializeEvent(com.velocitypowered.api.event.proxy.ProxyInitializeEvent) ThreadFactory(java.util.concurrent.ThreadFactory) ServerPostConnectEvent(com.velocitypowered.api.event.player.ServerPostConnectEvent) Method(java.lang.reflect.Method) Path(java.nio.file.Path) ChatResult(com.velocitypowered.api.event.player.PlayerChatEvent.ChatResult) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) TextComponent(net.kyori.adventure.text.TextComponent) ForwardResult(com.velocitypowered.api.event.connection.PluginMessageEvent.ForwardResult) Filter(org.apache.logging.log4j.core.Filter) JSONParser(org.json.simple.parser.JSONParser) SynchronousQueue(java.util.concurrent.SynchronousQueue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) VelocityServerConnection(com.velocitypowered.proxy.connection.backend.VelocityServerConnection) ChannelPipeline(io.netty.channel.ChannelPipeline) UUID(java.util.UUID) RegisteredServer(com.velocitypowered.api.proxy.server.RegisteredServer) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) JSONObject(org.json.simple.JSONObject) ClickEventAction(com.loohp.interactivechat.objectholders.CustomPlaceholder.ClickEventAction) ByteStreams(com.google.common.io.ByteStreams) Subscribe(com.velocitypowered.api.event.Subscribe) Optional(java.util.Optional) ChannelMessageSource(com.velocitypowered.api.proxy.messages.ChannelMessageSource) Pattern(java.util.regex.Pattern) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) HoverEvent(net.kyori.adventure.text.event.HoverEvent) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) ProxyPlayerCooldownManager(com.loohp.interactivechat.proxy.objectholders.ProxyPlayerCooldownManager) DisconnectEvent(com.velocitypowered.api.event.connection.DisconnectEvent) ServerConnection(com.velocitypowered.api.proxy.ServerConnection) Metrics(com.loohp.interactivechat.proxy.velocity.metrics.Metrics) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) Connections(com.velocitypowered.proxy.network.Connections) Registry(com.loohp.interactivechat.registry.Registry) Charts(com.loohp.interactivechat.proxy.velocity.metrics.Charts) Config(com.loohp.interactivechat.config.Config) DataTypeIO(com.loohp.interactivechat.utils.DataTypeIO) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) ArrayList(java.util.ArrayList) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Chat(com.velocitypowered.proxy.protocol.packet.Chat) PlayerChatEvent(com.velocitypowered.api.event.player.PlayerChatEvent) ParseException(org.json.simple.parser.ParseException) PostOrder(com.velocitypowered.api.event.PostOrder) Component(net.kyori.adventure.text.Component) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) PostLoginEvent(com.velocitypowered.api.event.connection.PostLoginEvent) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) BackendInteractiveChatData(com.loohp.interactivechat.proxy.objectholders.BackendInteractiveChatData) IOException(java.io.IOException) Field(java.lang.reflect.Field) InputStreamReader(java.io.InputStreamReader) File(java.io.File) DataDirectory(com.velocitypowered.api.plugin.annotation.DataDirectory) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) LogFilter(com.loohp.interactivechat.objectholders.LogFilter) CommandSource(com.velocitypowered.api.command.CommandSource) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) ProxyMessageForwardingHandler(com.loohp.interactivechat.proxy.objectholders.ProxyMessageForwardingHandler) NativeAdventureConverter(com.loohp.interactivechat.utils.NativeAdventureConverter) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) ArrayList(java.util.ArrayList) VelocityServerConnection(com.velocitypowered.proxy.connection.backend.VelocityServerConnection) ServerConnection(com.velocitypowered.api.proxy.ServerConnection) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) IOException(java.io.IOException) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) ByteBuffer(java.nio.ByteBuffer) ChannelMessageSource(com.velocitypowered.api.proxy.messages.ChannelMessageSource) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) RegisteredServer(com.velocitypowered.api.proxy.server.RegisteredServer) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) UUID(java.util.UUID) Subscribe(com.velocitypowered.api.event.Subscribe)

Example 2 with BuiltInPlaceholder

use of com.loohp.interactivechat.objectholders.BuiltInPlaceholder in project InteractiveChat by LOOHP.

the class ConfigManager method loadConfig.

@SuppressWarnings("deprecation")
public static void loadConfig() {
    InteractiveChat.commandsEventPriority = EventPriority.valueOf(getConfig().getString("Settings.EventPriorities.Commands").toUpperCase());
    InteractiveChat.chatEventPriority = EventPriority.valueOf(getConfig().getString("Settings.EventPriorities.Chat").toUpperCase());
    InteractiveChat.itemTagMaxLength = getConfig().getInt("Settings.ItemTagMaxLength");
    InteractiveChat.packetStringMaxLength = getConfig().getInt("Settings.PacketStringMaxLength");
    InteractiveChat.parsePAPIOnMainThread = getConfig().getBoolean("Settings.ParsePAPIOnMainThread");
    InteractiveChat.useAccurateSenderFinder = getConfig().getBoolean("Settings.UseAccurateSenderParser");
    InteractiveChat.tagEveryIdentifiableMessage = getConfig().getBoolean("Settings.TagEveryIdentifiableMessage");
    String colorCodeString = getConfig().getString("Chat.TranslateAltColorCode");
    InteractiveChat.chatAltColorCode = colorCodeString.length() == 1 ? Optional.of(colorCodeString.charAt(0)) : Optional.empty();
    InteractiveChat.useCustomPlaceholderPermissions = getConfig().getBoolean("Settings.UseCustomPlaceholderPermissions");
    InteractiveChat.filterUselessColorCodes = getConfig().getBoolean("Settings.FilterUselessColorCodes", true);
    InteractiveChat.allowMention = getConfig().getBoolean("Chat.AllowMention");
    InteractiveChat.disableHere = getConfig().getBoolean("Chat.DisableHere");
    InteractiveChat.disableEveryone = getConfig().getBoolean("Chat.DisableEveryone");
    InteractiveChat.universalCooldown = getConfig().getLong("Settings.UniversalCooldown") * 1000;
    InteractiveChat.noPermissionMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.NoPermission"));
    InteractiveChat.invExpiredMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.InvExpired"));
    InteractiveChat.reloadPluginMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.ReloadPlugin"));
    InteractiveChat.noConsoleMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.PlayerOnlyCommand"));
    InteractiveChat.invalidPlayerMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.InvalidPlayer"));
    InteractiveChat.listPlaceholderHeader = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.ListPlaceholdersHeader"));
    InteractiveChat.listPlaceholderBody = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.ListPlaceholdersBody"));
    InteractiveChat.notEnoughArgs = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.NoEnoughArgs"));
    InteractiveChat.invalidArgs = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.InvalidArgs"));
    InteractiveChat.setInvDisplayLayout = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.SetInventoryDisplayLayout"));
    InteractiveChat.placeholderCooldownMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.PlaceholderCooldown"));
    InteractiveChat.universalCooldownMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.UniversalCooldown"));
    InteractiveChat.useItem = getConfig().getBoolean("ItemDisplay.Item.Enabled");
    InteractiveChat.useInventory = getConfig().getBoolean("ItemDisplay.Inventory.Enabled");
    InteractiveChat.useEnder = getConfig().getBoolean("ItemDisplay.EnderChest.Enabled");
    InteractiveChat.itemMapPreview = getConfig().getBoolean("ItemDisplay.Item.PreviewMaps");
    InteractiveChat.itemPlaceholder = Pattern.compile(getConfig().getString("ItemDisplay.Item.Keyword"));
    InteractiveChat.invPlaceholder = Pattern.compile(getConfig().getString("ItemDisplay.Inventory.Keyword"));
    InteractiveChat.enderPlaceholder = Pattern.compile(getConfig().getString("ItemDisplay.EnderChest.Keyword"));
    InteractiveChat.itemReplaceText = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Item.Text"));
    InteractiveChat.itemSingularReplaceText = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Item.SingularText"));
    InteractiveChat.invReplaceText = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Inventory.Text"));
    InteractiveChat.enderReplaceText = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.EnderChest.Text"));
    InteractiveChat.itemAirAllow = getConfig().getBoolean("ItemDisplay.Item.EmptyItemSettings.AllowAir");
    InteractiveChat.itemAirErrorMessage = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Item.EmptyItemSettings.DisallowMessage"));
    InteractiveChat.itemTitle = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Item.InventoryTitle"));
    InteractiveChat.invTitle = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Inventory.InventoryTitle"));
    InteractiveChat.enderTitle = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.EnderChest.InventoryTitle"));
    InteractiveChat.itemHover = getConfig().getBoolean("ItemDisplay.Item.HoverEnabled");
    InteractiveChat.itemAlternativeHoverMessage = ChatColorUtils.translateAlternateColorCodes('&', String.join("\n", getConfig().getStringList("ItemDisplay.Item.AlternativeHoverMessage")));
    InteractiveChat.itemGUI = getConfig().getBoolean("ItemDisplay.Item.GUIEnabled");
    InteractiveChat.translateHoverableItems = getConfig().getBoolean("ItemDisplay.Item.HoverableItemsTranslation.Enabled");
    InteractiveChat.hoverableItemTitle = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Item.HoverableItemsTranslation.InventoryTitle"));
    InteractiveChat.containerViewTitle = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Settings.ContainerViewTitle"));
    try {
        try {
            if (VERSION.isLegacy()) {
                String str = getConfig().getString("ItemDisplay.Item.Frame.Primary");
                Material material = str.contains(":") ? Material.valueOf(str.substring(0, str.lastIndexOf(":"))) : Material.valueOf(str);
                short data = str.contains(":") ? Short.valueOf(str.substring(str.lastIndexOf(":") + 1)) : 0;
                InteractiveChat.itemFrame1 = new ItemStack(material, 1, data);
            } else {
                InteractiveChat.itemFrame1 = new ItemStack(Material.valueOf(getConfig().getString("ItemDisplay.Item.Frame.Primary")), 1);
            }
        } catch (Exception e) {
            InteractiveChat.itemFrame1 = XMaterialUtils.matchXMaterial(getConfig().getString("ItemDisplay.Item.Frame.Primary")).parseItem();
            InteractiveChat.itemFrame1.setAmount(1);
        }
    } catch (Exception e) {
        Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You have an invalid material name in the config! Please take a look at the Q&A section on the resource page! (ItemDisplay.Item.Frame.Primary)");
        e.printStackTrace();
    }
    try {
        try {
            if (VERSION.isLegacy()) {
                String str = getConfig().getString("ItemDisplay.Item.Frame.Secondary");
                Material material = str.contains(":") ? Material.valueOf(str.substring(0, str.lastIndexOf(":"))) : Material.valueOf(str);
                short data = str.contains(":") ? Short.valueOf(str.substring(str.lastIndexOf(":") + 1)) : 0;
                InteractiveChat.itemFrame2 = new ItemStack(material, 1, data);
            } else {
                InteractiveChat.itemFrame2 = new ItemStack(Material.valueOf(getConfig().getString("ItemDisplay.Item.Frame.Secondary")), 1);
            }
        } catch (Exception e) {
            InteractiveChat.itemFrame2 = XMaterialUtils.matchXMaterial(getConfig().getString("ItemDisplay.Item.Frame.Secondary")).parseItem();
            InteractiveChat.itemFrame2.setAmount(1);
        }
    } catch (Exception e) {
        Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You have an invalid material name in the config! Please take a look at the Q&A section on the resource page! (ItemDisplay.Item.Frame.Secondary)");
        e.printStackTrace();
    }
    try {
        try {
            if (VERSION.isLegacy()) {
                String str = getConfig().getString("ItemDisplay.Inventory.Frame.Primary");
                Material material = str.contains(":") ? Material.valueOf(str.substring(0, str.lastIndexOf(":"))) : Material.valueOf(str);
                short data = str.contains(":") ? Short.valueOf(str.substring(str.lastIndexOf(":") + 1)) : 0;
                InteractiveChat.invFrame1 = new ItemStack(material, 1, data);
            } else {
                InteractiveChat.invFrame1 = new ItemStack(Material.valueOf(getConfig().getString("ItemDisplay.Inventory.Frame.Primary")), 1);
            }
        } catch (Exception e) {
            InteractiveChat.invFrame1 = XMaterialUtils.matchXMaterial(getConfig().getString("ItemDisplay.Inventory.Frame.Primary")).parseItem();
            InteractiveChat.invFrame1.setAmount(1);
        }
    } catch (Exception e) {
        Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You have an invalid material name in the config! Please take a look at the Q&A section on the resource page! (ItemDisplay.Inventory.Frame.Primary)");
        e.printStackTrace();
    }
    try {
        try {
            if (VERSION.isLegacy()) {
                String str = getConfig().getString("ItemDisplay.Inventory.Frame.Secondary");
                Material material = str.contains(":") ? Material.valueOf(str.substring(0, str.lastIndexOf(":"))) : Material.valueOf(str);
                short data = str.contains(":") ? Short.valueOf(str.substring(str.lastIndexOf(":") + 1)) : 0;
                InteractiveChat.invFrame2 = new ItemStack(material, 1, data);
            } else {
                InteractiveChat.invFrame2 = new ItemStack(Material.valueOf(getConfig().getString("ItemDisplay.Inventory.Frame.Secondary")), 1);
            }
        } catch (Exception e) {
            InteractiveChat.invFrame2 = XMaterialUtils.matchXMaterial(getConfig().getString("ItemDisplay.Inventory.Frame.Secondary")).parseItem();
            InteractiveChat.invFrame2.setAmount(1);
        }
    } catch (Exception e) {
        Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You have an invalid material name in the config! Please take a look at the Q&A section on the resource page! (ItemDisplay.Inventory.Frame.Secondary)");
        e.printStackTrace();
    }
    InteractiveChat.invSkullName = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Inventory.SkullDisplayName"));
    InteractiveChat.invDisplayLayout = getConfig().getInt("ItemDisplay.Inventory.Layout");
    InteractiveChat.itemDisplayTimeout = getConfig().getLong("ItemDisplay.Settings.Timeout") * 60 * 1000;
    if (getConfig().contains("Secret.t")) {
        InteractiveChat.t = getConfig().getBoolean("Secret.t");
    }
    InteractiveChat.usePlayerName = getConfig().getBoolean("Player.UsePlayerNameInteraction");
    InteractiveChat.usePlayerNameOverrideHover = getConfig().getBoolean("Player.OverrideOriginal.HoverEvent");
    InteractiveChat.usePlayerNameOverrideClick = getConfig().getBoolean("Player.OverrideOriginal.ClickEvent");
    InteractiveChat.usePlayerNameHoverEnable = getConfig().getBoolean("Player.Hover.Enable");
    List<String> stringList = getConfig().getStringList("Player.Hover.Text");
    InteractiveChat.usePlayerNameHoverText = ChatColorUtils.translateAlternateColorCodes('&', String.join("\n", stringList));
    InteractiveChat.usePlayerNameClickEnable = getConfig().getBoolean("Player.Click.Enable");
    InteractiveChat.usePlayerNameClickAction = getConfig().getString("Player.Click.Action");
    InteractiveChat.usePlayerNameClickValue = getConfig().getString("Player.Click.Value");
    InteractiveChat.usePlayerNameCaseSensitive = getConfig().getBoolean("Player.CaseSensitive");
    InteractiveChat.useTooltipOnTab = getConfig().getBoolean("TabCompletion.PlayerNameToolTip.Enabled");
    InteractiveChat.tabTooltip = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("TabCompletion.PlayerNameToolTip.ToolTip"));
    InteractiveChat.playerNotFoundHoverEnable = getConfig().getBoolean("Settings.PlayerNotFound.Hover.Enable");
    List<String> stringList2 = getConfig().getStringList("Settings.PlayerNotFound.Hover.Text");
    InteractiveChat.playerNotFoundHoverText = ChatColorUtils.translateAlternateColorCodes('&', String.join("\n", stringList2));
    InteractiveChat.playerNotFoundClickEnable = getConfig().getBoolean("Settings.PlayerNotFound.Click.Enable");
    InteractiveChat.playerNotFoundClickAction = getConfig().getString("Settings.PlayerNotFound.Click.Action");
    InteractiveChat.playerNotFoundClickValue = getConfig().getString("Settings.PlayerNotFound.Click.Value");
    InteractiveChat.playerNotFoundReplaceEnable = getConfig().getBoolean("Settings.PlayerNotFound.Replace.Enable");
    InteractiveChat.playerNotFoundReplaceText = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Settings.PlayerNotFound.Replace.ReplaceText"));
    InteractiveChat.placeholderList.clear();
    if (InteractiveChat.useItem) {
        String name = InteractiveChat.itemName = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Item.Name"));
        String description = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Item.Description"));
        ICPlaceholder itemPlaceholder = new BuiltInPlaceholder(InteractiveChat.itemPlaceholder, name, description, "interactivechat.module.item", getConfig().getLong("ItemDisplay.Item.Cooldown") * 1000);
        InteractiveChat.placeholderList.put(itemPlaceholder.getInternalId(), itemPlaceholder);
    }
    if (InteractiveChat.useInventory) {
        String name = InteractiveChat.invName = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Inventory.Name"));
        String description = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.Inventory.Description"));
        ICPlaceholder invPlaceholder = new BuiltInPlaceholder(InteractiveChat.invPlaceholder, name, description, "interactivechat.module.inventory", getConfig().getLong("ItemDisplay.Inventory.Cooldown") * 1000);
        InteractiveChat.placeholderList.put(invPlaceholder.getInternalId(), invPlaceholder);
    }
    if (InteractiveChat.useEnder) {
        String name = InteractiveChat.enderName = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.EnderChest.Name"));
        String description = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("ItemDisplay.EnderChest.Description"));
        ICPlaceholder enderPlaceholder = new BuiltInPlaceholder(InteractiveChat.enderPlaceholder, name, description, "interactivechat.module.enderchest", getConfig().getLong("ItemDisplay.EnderChest.Cooldown") * 1000);
        InteractiveChat.placeholderList.put(enderPlaceholder.getInternalId(), enderPlaceholder);
    }
    for (int customNo = 1; ConfigManager.getConfig().contains("CustomPlaceholders." + customNo); customNo++) {
        ConfigurationSection s = getConfig().getConfigurationSection("CustomPlaceholders." + customNo);
        ParsePlayer parseplayer = ParsePlayer.fromString(s.getString("ParsePlayer"));
        String placeholder = s.getString("Keyword");
        boolean parseKeyword = s.getBoolean("ParseKeyword");
        long cooldown = s.getLong("Cooldown") * 1000;
        boolean hoverEnabled = s.getBoolean("Hover.Enable");
        String hoverText = ChatColorUtils.translateAlternateColorCodes('&', String.join("\n", s.getStringList("Hover.Text")));
        boolean clickEnabled = s.getBoolean("Click.Enable");
        String clickAction = s.getString("Click.Action").toUpperCase();
        String clickValue = s.getString("Click.Value");
        boolean replaceEnabled = s.getBoolean("Replace.Enable");
        String replaceText = ChatColorUtils.translateAlternateColorCodes('&', s.getString("Replace.ReplaceText"));
        String name = ChatColorUtils.translateAlternateColorCodes('&', s.getString("Name", placeholder.replace("\\", "")));
        String description = ChatColorUtils.translateAlternateColorCodes('&', s.getString("Description", "&7&oDescription missing"));
        ICPlaceholder customPlaceholder = new CustomPlaceholder(customNo, parseplayer, Pattern.compile(placeholder), parseKeyword, cooldown, new CustomPlaceholderHoverEvent(hoverEnabled, hoverText), new CustomPlaceholderClickEvent(clickEnabled, clickEnabled ? ClickEventAction.valueOf(clickAction) : null, clickValue), new CustomPlaceholderReplaceText(replaceEnabled, replaceText), name, description);
        InteractiveChat.placeholderList.put(customPlaceholder.getInternalId(), customPlaceholder);
    }
    if (InteractiveChat.bungeecordMode) {
        InteractiveChat.queueRemoteUpdate = true;
    }
    InteractiveChat.commandList = getConfig().getStringList("Settings.CommandsToParse");
    InteractiveChat.maxPlaceholders = getConfig().getInt("Settings.MaxPlaceholders");
    InteractiveChat.limitReachMessage = getConfig().getString("Messages.LimitReached");
    InteractiveChat.mentionPrefix = getConfig().getString("Chat.MentionPrefix");
    InteractiveChat.mentionHighlight = getConfig().getString("Chat.MentionHighlight");
    List<String> stringList3 = getConfig().getStringList("Chat.MentionHoverText");
    InteractiveChat.mentionHover = String.join("\n", stringList3);
    InteractiveChat.mentionDuration = getConfig().getDouble("Chat.MentionedTitleDuration");
    InteractiveChat.mentionCooldown = (long) (getConfig().getDouble("Chat.MentionCooldown") * 1000);
    InteractiveChat.mentionEnable = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.EnableMentions"));
    InteractiveChat.mentionDisable = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Messages.DisableMentions"));
    InteractiveChat.mentionTitle = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Chat.MentionedTitle"));
    InteractiveChat.mentionSubtitle = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Chat.KnownPlayerMentionSubtitle"));
    InteractiveChat.mentionActionbar = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Chat.KnownPlayerMentionActionbar"));
    InteractiveChat.mentionToast = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Chat.MentionToast"));
    InteractiveChat.mentionBossBarText = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Chat.MentionBossBar.Text"));
    InteractiveChat.mentionBossBarColorName = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Chat.MentionBossBar.Color"));
    InteractiveChat.mentionBossBarOverlayName = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Chat.MentionBossBar.Overlay"));
    InteractiveChat.mentionSound = getConfig().getString("Chat.MentionedSound");
    InteractiveChat.mentionTitleDuration = (int) Math.round(ConfigManager.getConfig().getDouble("Chat.MentionedTitleDuration") * 20);
    InteractiveChat.mentionBossBarDuration = (int) Math.round(ConfigManager.getConfig().getDouble("Chat.MentionBossBar.Duration") * 20);
    InteractiveChat.mentionBossBarRemoveDelay = (int) Math.round(ConfigManager.getConfig().getDouble("Chat.MentionBossBar.RemoveDelay") * 20);
    InteractiveChat.updaterEnabled = getConfig().getBoolean("Options.Updater");
    InteractiveChat.cancelledMessage = getConfig().getBoolean("Options.ShowCancelledNotice");
    InteractiveChat.clickableCommands = getConfig().getBoolean("Commands.Enabled");
    InteractiveChat.clickableCommandsFormat = getConfig().getString("Commands.Format");
    InteractiveChat.clickableCommandsAction = ClickEvent.Action.valueOf(getConfig().getString("Commands.Action"));
    InteractiveChat.clickableCommandsDisplay = ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Commands.Text"));
    InteractiveChat.clickableCommandsHoverText = ChatColorUtils.translateAlternateColorCodes('&', String.join("\n", getConfig().getStringList("Commands.HoverMessage")));
    InteractiveChat.sendOriginalIfTooLong = getConfig().getBoolean("Settings.SendOriginalMessageIfExceedLengthLimit");
    InteractiveChat.messageToIgnore = new HashSet<>(getConfig().getStringList("Settings.MessagesToIgnore"));
    try {
        try {
            if (VERSION.isLegacy()) {
                String str = getConfig().getString("ItemDisplay.Item.Frame.Secondary");
                Material material = str.contains(":") ? Material.valueOf(str.substring(0, str.lastIndexOf(":"))) : Material.valueOf(str);
                short data = str.contains(":") ? Short.valueOf(str.substring(str.lastIndexOf(":") + 1)) : 0;
                ItemStack unknown = new ItemStack(material, 1, data);
                ItemMeta meta = unknown.getItemMeta();
                meta.setDisplayName(ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Settings.BungeecordUnknownItem.DisplayName")));
                meta.setLore(getConfig().getStringList("Settings.BungeecordUnknownItem.Lore").stream().map(each -> ChatColorUtils.translateAlternateColorCodes('&', each)).collect(Collectors.toList()));
                unknown.setItemMeta(meta);
                InteractiveChat.unknownReplaceItem = unknown;
            } else {
                ItemStack unknown = new ItemStack(Material.valueOf(getConfig().getString("Settings.BungeecordUnknownItem.ReplaceItem").toUpperCase()));
                ItemMeta meta = unknown.getItemMeta();
                meta.setDisplayName(ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Settings.BungeecordUnknownItem.DisplayName")));
                meta.setLore(getConfig().getStringList("Settings.BungeecordUnknownItem.Lore").stream().map(each -> ChatColorUtils.translateAlternateColorCodes('&', each)).collect(Collectors.toList()));
                unknown.setItemMeta(meta);
                InteractiveChat.unknownReplaceItem = unknown;
            }
        } catch (Exception e) {
            ItemStack unknown = XMaterialUtils.matchXMaterial(getConfig().getString("Settings.BungeecordUnknownItem.ReplaceItem")).parseItem();
            unknown.setAmount(1);
            ItemMeta meta = unknown.getItemMeta();
            meta.setDisplayName(ChatColorUtils.translateAlternateColorCodes('&', getConfig().getString("Settings.BungeecordUnknownItem.DisplayName")));
            meta.setLore(getConfig().getStringList("Settings.BungeecordUnknownItem.Lore").stream().map(each -> ChatColorUtils.translateAlternateColorCodes('&', each)).collect(Collectors.toList()));
            unknown.setItemMeta(meta);
            InteractiveChat.unknownReplaceItem = unknown;
        }
    } catch (Exception e) {
        Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You have an invalid material name in the config! Please take a look at the Q&A section on the resource page! (Settings.BungeecordUnknownItem.ReplaceItem)");
        e.printStackTrace();
    }
    InteractiveChat.useBukkitDisplayName = getConfig().getBoolean("Chat.UseBukkitDisplayName");
    InteractiveChat.useEssentialsNicknames = getConfig().getBoolean("Chat.UseEssentialsNicknames");
    InteractiveChat.rgbTags = getConfig().getBoolean("Settings.FormattingTags.AllowRGBTags");
    InteractiveChat.fontTags = getConfig().getBoolean("Settings.FormattingTags.AllowFontTags");
    InteractiveChat.additionalRGBFormats = getConfig().getStringList("Settings.FormattingTags.AdditionalRGBFormats").stream().map(each -> Pattern.compile(each)).collect(Collectors.toList());
    InteractiveChat.language = getConfig().getString("Settings.Language");
    Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> {
        LanguageUtils.loadTranslations(InteractiveChat.language);
        if (WebData.getInstance() == null) {
            WebData.newInstance();
        } else {
            WebData.getInstance().reload();
        }
    });
    InteractiveChat.itemDisplay.clearAndSetTimeout(InteractiveChat.itemDisplayTimeout);
    InteractiveChat.inventoryDisplay.clearAndSetTimeout(InteractiveChat.itemDisplayTimeout);
    InteractiveChat.inventoryDisplay1Upper.clearAndSetTimeout(InteractiveChat.itemDisplayTimeout);
    InteractiveChat.inventoryDisplay1Lower.clearAndSetTimeout(InteractiveChat.itemDisplayTimeout);
    InteractiveChat.enderDisplay.clearAndSetTimeout(InteractiveChat.itemDisplayTimeout);
    InteractiveChat.mapDisplay.clearAndSetTimeout(InteractiveChat.itemDisplayTimeout);
    InteractiveChat.upperSharedInventory.clear();
    InteractiveChat.lowerSharedInventory.clear();
}
Also used : MCVersion(com.loohp.interactivechat.utils.MCVersion) ItemMeta(org.bukkit.inventory.meta.ItemMeta) CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) WebData(com.loohp.interactivechat.objectholders.WebData) ConfigDataFixer(com.loohp.interactivechat.datafixer.ConfigDataFixer) ConfigurationSection(com.loohp.yamlconfiguration.ConfigurationSection) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) ClickEvent(net.kyori.adventure.text.event.ClickEvent) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) HashSet(java.util.HashSet) LanguageUtils(com.loohp.interactivechat.utils.LanguageUtils) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) Material(org.bukkit.Material) ChatColor(net.md_5.bungee.api.ChatColor) Bukkit(org.bukkit.Bukkit) YamlConfiguration(com.loohp.yamlconfiguration.YamlConfiguration) XMaterialUtils(com.loohp.interactivechat.utils.XMaterialUtils) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) ItemStack(org.bukkit.inventory.ItemStack) InteractiveChat(com.loohp.interactivechat.InteractiveChat) List(java.util.List) ClickEventAction(com.loohp.interactivechat.objectholders.CustomPlaceholder.ClickEventAction) EventPriority(org.bukkit.event.EventPriority) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) ChatColorUtils(com.loohp.interactivechat.utils.ChatColorUtils) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) Material(org.bukkit.Material) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) IOException(java.io.IOException) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) ConfigurationSection(com.loohp.yamlconfiguration.ConfigurationSection)

Example 3 with BuiltInPlaceholder

use of com.loohp.interactivechat.objectholders.BuiltInPlaceholder in project InteractiveChat by LOOHP.

the class InteractiveChatBungee method onReceive.

@EventHandler
public void onReceive(PluginMessageEvent event) {
    if (!event.getTag().equals("interchat:main")) {
        return;
    }
    event.setCancelled(true);
    Server senderServer = (Server) event.getSender();
    SocketAddress senderServerAddress = event.getSender().getSocketAddress();
    byte[] packet = Arrays.copyOf(event.getData(), event.getData().length);
    ByteArrayDataInput in = ByteStreams.newDataInput(packet);
    int packetNumber = in.readInt();
    int packetId = in.readShort();
    if (!Registry.PROXY_PASSTHROUGH_RELAY_PACKETS.contains(packetId)) {
        boolean isEnding = in.readBoolean();
        byte[] data = new byte[packet.length - 7];
        in.readFully(data);
        byte[] chain = incomming.remove(packetNumber);
        if (chain != null) {
            ByteBuffer buff = ByteBuffer.allocate(chain.length + data.length);
            buff.put(chain);
            buff.put(data);
            data = buff.array();
        }
        if (!isEnding) {
            incomming.put(packetNumber, data);
            return;
        }
        byte[] finalData = data;
        pluginMessageHandlingExecutor.submit(() -> {
            try {
                ByteArrayDataInput input = ByteStreams.newDataInput(finalData);
                switch(packetId) {
                    case 0x07:
                        int cooldownType = input.readByte();
                        switch(cooldownType) {
                            case 0:
                                UUID uuid = DataTypeIO.readUUID(input);
                                long time = input.readLong();
                                playerCooldownManager.setPlayerUniversalLastTimestamp(uuid, time);
                                break;
                            case 1:
                                uuid = DataTypeIO.readUUID(input);
                                UUID internalId = DataTypeIO.readUUID(input);
                                time = input.readLong();
                                playerCooldownManager.setPlayerPlaceholderLastTimestamp(uuid, internalId, time);
                                break;
                        }
                        for (ServerInfo server : getProxy().getServers().values()) {
                            if (!server.getSocketAddress().equals(senderServerAddress) && server.getPlayers().size() > 0) {
                                server.sendData("interchat:main", finalData);
                                pluginMessagesCounter.incrementAndGet();
                            }
                        }
                        break;
                    case 0x08:
                        UUID messageId = DataTypeIO.readUUID(input);
                        String component = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        messageForwardingHandler.receivedProcessedMessage(messageId, component);
                        break;
                    case 0x09:
                        loadConfig();
                        break;
                    case 0x0B:
                        int id = input.readInt();
                        boolean permissionValue = input.readBoolean();
                        permissionChecks.put(id, permissionValue);
                        break;
                    case 0x0C:
                        int size1 = input.readInt();
                        List<ICPlaceholder> list = new ArrayList<>(size1);
                        for (int i = 0; i < size1; i++) {
                            boolean isBulitIn = input.readBoolean();
                            if (isBulitIn) {
                                String keyword = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String name = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String description = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String permission = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                long cooldown = input.readLong();
                                list.add(new BuiltInPlaceholder(Pattern.compile(keyword), name, description, permission, cooldown));
                            } else {
                                int customNo = input.readInt();
                                ParsePlayer parseplayer = ParsePlayer.fromOrder(input.readByte());
                                String placeholder = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                boolean parseKeyword = input.readBoolean();
                                long cooldown = input.readLong();
                                boolean hoverEnabled = input.readBoolean();
                                String hoverText = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                boolean clickEnabled = input.readBoolean();
                                String clickAction = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String clickValue = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                boolean replaceEnabled = input.readBoolean();
                                String replaceText = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String name = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                String description = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                                list.add(new CustomPlaceholder(customNo, parseplayer, Pattern.compile(placeholder), parseKeyword, cooldown, new CustomPlaceholderHoverEvent(hoverEnabled, hoverText), new CustomPlaceholderClickEvent(clickEnabled, clickEnabled ? ClickEventAction.valueOf(clickAction) : null, clickValue), new CustomPlaceholderReplaceText(replaceEnabled, replaceText), name, description));
                            }
                        }
                        placeholderList.put(senderServer.getInfo().getName(), list);
                        playerCooldownManager.reloadPlaceholders(placeholderList.values().stream().flatMap(each -> each.stream()).distinct().collect(Collectors.toList()));
                        PluginMessageSendingBungee.forwardPlaceholderList(list, senderServer.getInfo());
                        break;
                    case 0x0D:
                        UUID uuid2 = DataTypeIO.readUUID(input);
                        PluginMessageSendingBungee.reloadPlayerData(uuid2, senderServer.getInfo());
                        break;
                    case 0x10:
                        UUID requestUUID = DataTypeIO.readUUID(input);
                        int requestType = input.readByte();
                        switch(requestType) {
                            case 0:
                                PluginMessageSendingBungee.respondPlayerListRequest(requestUUID, senderServer.getInfo());
                                break;
                            default:
                                break;
                        }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    } else {
        pluginMessageHandlingExecutor.submit(() -> {
            for (ServerInfo server : getProxy().getServers().values()) {
                if (!server.getSocketAddress().equals(senderServerAddress) && server.getPlayers().size() > 0) {
                    server.sendData("interchat:main", event.getData());
                    pluginMessagesCounter.incrementAndGet();
                }
            }
        });
    }
}
Also used : Charts(com.loohp.interactivechat.proxy.bungee.metrics.Charts) Arrays(java.util.Arrays) PlayerUtils(com.loohp.interactivechat.utils.PlayerUtils) SocketAddress(java.net.SocketAddress) PostLoginEvent(net.md_5.bungee.api.event.PostLoginEvent) Random(java.util.Random) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) UserConnection(net.md_5.bungee.UserConnection) ByteBuffer(java.nio.ByteBuffer) Via(us.myles.ViaVersion.api.Via) EventPriority(net.md_5.bungee.event.EventPriority) InteractiveChatComponentSerializer(com.loohp.interactivechat.utils.InteractiveChatComponentSerializer) Matcher(java.util.regex.Matcher) ChannelPromise(io.netty.channel.ChannelPromise) Chat(net.md_5.bungee.protocol.packet.Chat) Map(java.util.Map) ThreadFactory(java.util.concurrent.ThreadFactory) Material(org.bukkit.Material) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) Listener(net.md_5.bungee.api.plugin.Listener) CommandSender(net.md_5.bungee.api.CommandSender) Filter(java.util.logging.Filter) SynchronousQueue(java.util.concurrent.SynchronousQueue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ChannelPipeline(io.netty.channel.ChannelPipeline) UUID(java.util.UUID) LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger) PlaceholderAPI(me.clip.placeholderapi.PlaceholderAPI) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) InteractiveChat(com.loohp.interactivechat.InteractiveChat) ChatEvent(net.md_5.bungee.api.event.ChatEvent) ComponentSerializer(net.md_5.bungee.chat.ComponentSerializer) List(java.util.List) ClickEventAction(com.loohp.interactivechat.objectholders.CustomPlaceholder.ClickEventAction) Server(net.md_5.bungee.api.connection.Server) ChannelWrapper(net.md_5.bungee.netty.ChannelWrapper) ByteStreams(com.google.common.io.ByteStreams) Entry(java.util.Map.Entry) ServerConnection(net.md_5.bungee.ServerConnection) Plugin(net.md_5.bungee.api.plugin.Plugin) Pattern(java.util.regex.Pattern) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) HoverEvent(net.kyori.adventure.text.event.HoverEvent) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) ProxyPlayerCooldownManager(com.loohp.interactivechat.proxy.objectholders.ProxyPlayerCooldownManager) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) Registry(com.loohp.interactivechat.registry.Registry) Config(com.loohp.interactivechat.config.Config) DataTypeIO(com.loohp.interactivechat.utils.DataTypeIO) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) ServerInfo(net.md_5.bungee.api.config.ServerInfo) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) ArrayList(java.util.ArrayList) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) LinkedHashMap(java.util.LinkedHashMap) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Component(net.kyori.adventure.text.Component) ServerConnectedEvent(net.md_5.bungee.api.event.ServerConnectedEvent) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) Metrics(com.loohp.interactivechat.proxy.bungee.metrics.Metrics) PlayerDisconnectEvent(net.md_5.bungee.api.event.PlayerDisconnectEvent) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) LegacyComponentSerializer(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer) ChatColor(net.md_5.bungee.api.ChatColor) Iterator(java.util.Iterator) BackendInteractiveChatData(com.loohp.interactivechat.proxy.objectholders.BackendInteractiveChatData) PluginMessageEvent(net.md_5.bungee.api.event.PluginMessageEvent) IOException(java.io.IOException) PipelineUtils(net.md_5.bungee.netty.PipelineUtils) ProxyServer(net.md_5.bungee.api.ProxyServer) Field(java.lang.reflect.Field) ServerSwitchEvent(net.md_5.bungee.api.event.ServerSwitchEvent) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) ChatColorUtils(com.loohp.interactivechat.utils.ChatColorUtils) EventHandler(net.md_5.bungee.event.EventHandler) Collections(java.util.Collections) ProxyMessageForwardingHandler(com.loohp.interactivechat.proxy.objectholders.ProxyMessageForwardingHandler) Server(net.md_5.bungee.api.connection.Server) ProxyServer(net.md_5.bungee.api.ProxyServer) ServerInfo(net.md_5.bungee.api.config.ServerInfo) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) ArrayList(java.util.ArrayList) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) IOException(java.io.IOException) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) ByteBuffer(java.nio.ByteBuffer) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) SocketAddress(java.net.SocketAddress) UUID(java.util.UUID) EventHandler(net.md_5.bungee.event.EventHandler)

Example 4 with BuiltInPlaceholder

use of com.loohp.interactivechat.objectholders.BuiltInPlaceholder in project InteractiveChat by LOOHP.

the class BungeeMessageListener method onPluginMessageReceived.

@SuppressWarnings("deprecation")
@Override
public void onPluginMessageReceived(String channel, Player pluginMessagingPlayer, byte[] bytes) {
    if (!channel.equals("interchat:main")) {
        return;
    }
    ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
    int packetNumber = in.readInt();
    int packetId = in.readShort();
    boolean isEnding = in.readBoolean();
    byte[] data = new byte[bytes.length - 7];
    in.readFully(data);
    byte[] chain = incoming.remove(packetNumber);
    if (chain != null) {
        ByteBuffer buff = ByteBuffer.allocate(chain.length + data.length);
        buff.put(chain);
        buff.put(data);
        data = buff.array();
    }
    if (!isEnding) {
        incoming.put(packetNumber, data);
        return;
    }
    try {
        ByteArrayDataInput input = ByteStreams.newDataInput(data);
        switch(packetId) {
            case 0x00:
                int playerAmount = input.readInt();
                Set<UUID> localUUID = Bukkit.getOnlinePlayers().stream().map(each -> each.getUniqueId()).collect(Collectors.toSet());
                Set<UUID> current = new HashSet<>(ICPlayerFactory.getRemoteUUIDs());
                Set<UUID> newSet = new HashSet<>();
                for (int i = 0; i < playerAmount; i++) {
                    String server = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                    UUID uuid = DataTypeIO.readUUID(input);
                    String name = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                    ICPlayer player = ICPlayerFactory.getICPlayer(uuid);
                    if (player != null) {
                        if (!player.getRemoteServer().equals(server)) {
                            player.setRemoteServer(server);
                        }
                    }
                    if (!localUUID.contains(uuid) && !ICPlayerFactory.getRemoteUUIDs().contains(uuid)) {
                        ICPlayerFactory.createOrUpdateRemoteICPlayer(server, name, uuid, true, 0, 0, Bukkit.createInventory(null, 45), Bukkit.createInventory(null, 36));
                    }
                    newSet.add(uuid);
                }
                current.removeAll(newSet);
                for (UUID uuid : current) {
                    ICPlayerFactory.removeRemoteICPlayer(uuid);
                }
                for (UUID uuid : localUUID) {
                    ICPlayerFactory.removeRemoteICPlayer(uuid);
                }
                break;
            case 0x01:
                int delay = input.readInt();
                short itemStackScheme = input.readShort();
                short inventoryScheme = input.readShort();
                InteractiveChat.remoteDelay = delay;
                BungeeMessageSender.itemStackScheme = itemStackScheme;
                BungeeMessageSender.inventoryScheme = inventoryScheme;
                break;
            case 0x02:
                UUID sender = DataTypeIO.readUUID(input);
                UUID receiver = DataTypeIO.readUUID(input);
                InteractiveChat.mentionPair.add(new MentionPair(sender, receiver));
                break;
            case 0x03:
                UUID uuid = DataTypeIO.readUUID(input);
                ICPlayer player = ICPlayerFactory.getICPlayer(uuid);
                if (player == null) {
                    break;
                }
                boolean rightHanded = input.readBoolean();
                player.setRemoteRightHanded(rightHanded);
                int selectedSlot = input.readByte();
                player.setRemoteSelectedSlot(selectedSlot);
                int level = input.readInt();
                player.setRemoteExperienceLevel(level);
                int size = input.readByte();
                ItemStack[] equipment = new ItemStack[size];
                for (int i = 0; i < equipment.length; i++) {
                    equipment[i] = DataTypeIO.readItemStack(input, StandardCharsets.UTF_8);
                }
                player.getEquipment().setHelmet(equipment[0]);
                player.getEquipment().setChestplate(equipment[1]);
                player.getEquipment().setLeggings(equipment[2]);
                player.getEquipment().setBoots(equipment[3]);
                if (InteractiveChat.version.isOld()) {
                    player.getEquipment().setItemInHand(equipment[4]);
                } else {
                    player.getEquipment().setItemInMainHand(equipment[4]);
                    player.getEquipment().setItemInOffHand(equipment[5]);
                }
                break;
            case 0x04:
                UUID uuid1 = DataTypeIO.readUUID(input);
                ICPlayer player1 = ICPlayerFactory.getICPlayer(uuid1);
                if (player1 == null) {
                    break;
                }
                boolean rightHanded1 = input.readBoolean();
                player1.setRemoteRightHanded(rightHanded1);
                int selectedSlot1 = input.readByte();
                player1.setRemoteSelectedSlot(selectedSlot1);
                int level1 = input.readInt();
                player1.setRemoteExperienceLevel(level1);
                int type = input.readByte();
                if (type == 0) {
                    player1.setRemoteInventory(DataTypeIO.readInventory(input, StandardCharsets.UTF_8));
                } else {
                    player1.setRemoteEnderChest(DataTypeIO.readInventory(input, StandardCharsets.UTF_8));
                }
                break;
            case 0x05:
                UUID uuid2 = DataTypeIO.readUUID(input);
                ICPlayer player2 = ICPlayerFactory.getICPlayer(uuid2);
                if (player2 == null) {
                    break;
                }
                int size1 = input.readInt();
                for (int i = 0; i < size1; i++) {
                    String placeholder = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                    String text = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                    player2.getRemotePlaceholdersMapping().put(placeholder, text);
                }
                break;
            case 0x06:
                String message = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                UUID uuid3 = DataTypeIO.readUUID(input);
                ICPlayer player3 = ICPlayerFactory.getICPlayer(uuid3);
                if (player3 == null) {
                    break;
                }
                InteractiveChat.messages.put(message, uuid3);
                Bukkit.getScheduler().runTaskLater(InteractiveChat.plugin, () -> InteractiveChat.messages.remove(message), 60);
                break;
            case 0x07:
                int cooldownType = input.readByte();
                switch(cooldownType) {
                    case 0:
                        UUID uuid4 = DataTypeIO.readUUID(input);
                        long time = input.readLong();
                        InteractiveChat.placeholderCooldownManager.setPlayerUniversalLastTimestampRaw(uuid4, time);
                        break;
                    case 1:
                        uuid4 = DataTypeIO.readUUID(input);
                        UUID internalId = DataTypeIO.readUUID(input);
                        time = input.readLong();
                        Optional<ICPlaceholder> optPlaceholder = InteractiveChat.placeholderList.values().stream().filter(each -> each.getInternalId().equals(internalId)).findFirst();
                        if (optPlaceholder.isPresent()) {
                            InteractiveChat.placeholderCooldownManager.setPlayerPlaceholderLastTimestampRaw(uuid4, optPlaceholder.get(), time);
                        }
                        break;
                }
                break;
            case 0x08:
                UUID messageId = DataTypeIO.readUUID(input);
                UUID uuid5 = DataTypeIO.readUUID(input);
                Player bukkitplayer1 = Bukkit.getPlayer(uuid5);
                if (bukkitplayer1 == null) {
                    break;
                }
                String component = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                Bukkit.getScheduler().runTaskAsynchronously(InteractiveChat.plugin, () -> {
                    try {
                        String processed = ProcessExternalMessage.processAndRespond(bukkitplayer1, component);
                        BungeeMessageSender.respondProcessedMessage(System.currentTimeMillis(), processed, messageId);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                break;
            case 0x09:
                String server = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                int size2 = input.readInt();
                List<ICPlaceholder> list = new ArrayList<>(size2);
                for (int i = 0; i < size2; i++) {
                    boolean isBulitIn = input.readBoolean();
                    if (isBulitIn) {
                        String keyword = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        String name = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        String description = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        String permission = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        long cooldown = input.readLong();
                        list.add(new BuiltInPlaceholder(Pattern.compile(keyword), name, description, permission, cooldown));
                    } else {
                        int customNo = input.readInt();
                        ParsePlayer parseplayer = ParsePlayer.fromOrder(input.readByte());
                        String placeholder = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        boolean parseKeyword = input.readBoolean();
                        long cooldown = input.readLong();
                        boolean hoverEnabled = input.readBoolean();
                        String hoverText = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        boolean clickEnabled = input.readBoolean();
                        String clickAction = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        String clickValue = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        boolean replaceEnabled = input.readBoolean();
                        String replaceText = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        String name = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        String description = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                        list.add(new CustomPlaceholder(customNo, parseplayer, Pattern.compile(placeholder), parseKeyword, cooldown, new CustomPlaceholderHoverEvent(hoverEnabled, hoverText), new CustomPlaceholderClickEvent(clickEnabled, clickEnabled ? ClickEventAction.valueOf(clickAction) : null, clickValue), new CustomPlaceholderReplaceText(replaceEnabled, replaceText), name, description));
                    }
                }
                InteractiveChat.remotePlaceholderList.put(server, list);
                break;
            case 0x0A:
                BungeeMessageSender.resetAndForwardPlaceholderList(System.currentTimeMillis(), InteractiveChat.placeholderList.values());
                break;
            case 0x0B:
                int id = input.readInt();
                UUID playerUUID = DataTypeIO.readUUID(input);
                String permission = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                Player player5 = Bukkit.getPlayer(playerUUID);
                BungeeMessageSender.permissionCheckResponse(System.currentTimeMillis(), id, player5 != null && player5.hasPermission(permission));
                break;
            case 0x0D:
                UUID playerUUID1 = DataTypeIO.readUUID(input);
                PlayerData pd = InteractiveChat.playerDataManager.getPlayerData(playerUUID1);
                if (pd != null) {
                    pd.reload();
                }
                break;
            case 0x0E:
                SharedType sharedType = SharedType.fromValue(input.readByte());
                String sha1 = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                Inventory inventory = DataTypeIO.readInventory(input, StandardCharsets.UTF_8);
                InteractiveChatAPI.addInventoryToItemShareList(sharedType, sha1, inventory);
                break;
            case 0x0F:
                int requestType = input.readByte();
                UUID playerUUID2 = DataTypeIO.readUUID(input);
                Player player6 = Bukkit.getPlayer(playerUUID2);
                if (player6 != null) {
                    ICPlayer player7 = ICPlayerFactory.getICPlayer(player6);
                    switch(requestType) {
                        case 0:
                            BungeeMessageSender.forwardInventory(System.currentTimeMillis(), player7.getUniqueId(), player7.isRightHanded(), player7.getSelectedSlot(), player7.getExperienceLevel(), null, player7.getInventory());
                            break;
                        case 1:
                            BungeeMessageSender.forwardEnderchest(System.currentTimeMillis(), player7.getUniqueId(), player7.isRightHanded(), player7.getSelectedSlot(), player7.getExperienceLevel(), null, player7.getEnderChest());
                            break;
                    }
                }
                break;
            case 0x10:
                UUID requestUUID = DataTypeIO.readUUID(input);
                int requestType2 = input.readByte();
                // noinspection SwitchStatementWithTooFewBranches
                switch(requestType2) {
                    case 0:
                        List<ValueTrios<UUID, String, Integer>> playerlist = new ArrayList<>();
                        int playerListSize = input.readInt();
                        for (int i = 0; i < playerListSize; i++) {
                            playerlist.add(new ValueTrios<>(DataTypeIO.readUUID(input), DataTypeIO.readString(input, StandardCharsets.UTF_8), input.readInt()));
                        }
                        @SuppressWarnings("unchecked") CompletableFuture<List<ValueTrios<UUID, String, Integer>>> future = (CompletableFuture<List<ValueTrios<UUID, String, Integer>>>) toComplete.remove(requestUUID);
                        if (future != null) {
                            future.complete(playerlist);
                        }
                        break;
                    default:
                        break;
                }
                break;
            case 0x11:
                UUID playerUUID3 = DataTypeIO.readUUID(input);
                int nicknameSize = input.readInt();
                Set<String> remoteNicknames = new HashSet<>();
                for (int i = 0; i < nicknameSize; i++) {
                    remoteNicknames.add(DataTypeIO.readString(input, StandardCharsets.UTF_8));
                }
                ICPlayer icPlayer = ICPlayerFactory.getICPlayer(playerUUID3);
                if (icPlayer != null) {
                    icPlayer.setRemoteNicknames(remoteNicknames);
                }
                break;
            case 0x12:
                UUID playerUUID4 = DataTypeIO.readUUID(input);
                String placeholders = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                ICPlayer icPlayer1 = ICPlayerFactory.getICPlayer(playerUUID4);
                if (icPlayer1 != null && icPlayer1.isLocal()) {
                    PlaceholderParser.parse(icPlayer1, placeholders);
                }
                break;
            case 0xFF:
                String customChannel = DataTypeIO.readString(input, StandardCharsets.UTF_8);
                int dataLength = input.readInt();
                byte[] customData = new byte[dataLength];
                input.readFully(customData);
                ProxyCustomDataRecievedEvent dataEvent = new ProxyCustomDataRecievedEvent(customChannel, customData);
                Bukkit.getPluginManager().callEvent(dataEvent);
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) InteractiveChatAPI(com.loohp.interactivechat.api.InteractiveChatAPI) PlayerData(com.loohp.interactivechat.data.PlayerDataManager.PlayerData) DataTypeIO(com.loohp.interactivechat.utils.DataTypeIO) TimeoutException(java.util.concurrent.TimeoutException) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) Player(org.bukkit.entity.Player) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) Inventory(org.bukkit.inventory.Inventory) ByteBuffer(java.nio.ByteBuffer) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ICPlayer(com.loohp.interactivechat.objectholders.ICPlayer) PluginMessageListener(org.bukkit.plugin.messaging.PluginMessageListener) ProcessExternalMessage(com.loohp.interactivechat.modules.ProcessExternalMessage) Map(java.util.Map) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) MentionPair(com.loohp.interactivechat.objectholders.MentionPair) SharedType(com.loohp.interactivechat.api.InteractiveChatAPI.SharedType) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) Bukkit(org.bukkit.Bukkit) ProxyCustomDataRecievedEvent(com.loohp.interactivechat.api.events.ProxyCustomDataRecievedEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) ItemStack(org.bukkit.inventory.ItemStack) InteractiveChat(com.loohp.interactivechat.InteractiveChat) List(java.util.List) ValueTrios(com.loohp.interactivechat.objectholders.ValueTrios) ClickEventAction(com.loohp.interactivechat.objectholders.CustomPlaceholder.ClickEventAction) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) ICPlayerFactory(com.loohp.interactivechat.objectholders.ICPlayerFactory) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) PlaceholderParser(com.loohp.interactivechat.utils.PlaceholderParser) ICPlayer(com.loohp.interactivechat.objectholders.ICPlayer) CustomPlaceholderHoverEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent) ArrayList(java.util.ArrayList) CustomPlaceholderReplaceText(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText) CompletableFuture(java.util.concurrent.CompletableFuture) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) CustomPlaceholder(com.loohp.interactivechat.objectholders.CustomPlaceholder) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) HashSet(java.util.HashSet) Player(org.bukkit.entity.Player) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) ICPlayer(com.loohp.interactivechat.objectholders.ICPlayer) ProxyCustomDataRecievedEvent(com.loohp.interactivechat.api.events.ProxyCustomDataRecievedEvent) SharedType(com.loohp.interactivechat.api.InteractiveChatAPI.SharedType) CustomPlaceholderClickEvent(com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) ByteBuffer(java.nio.ByteBuffer) TimeoutException(java.util.concurrent.TimeoutException) ParsePlayer(com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer) BuiltInPlaceholder(com.loohp.interactivechat.objectholders.BuiltInPlaceholder) MentionPair(com.loohp.interactivechat.objectholders.MentionPair) ItemStack(org.bukkit.inventory.ItemStack) PlayerData(com.loohp.interactivechat.data.PlayerDataManager.PlayerData) Inventory(org.bukkit.inventory.Inventory) ValueTrios(com.loohp.interactivechat.objectholders.ValueTrios)

Aggregations

BuiltInPlaceholder (com.loohp.interactivechat.objectholders.BuiltInPlaceholder)4 CustomPlaceholder (com.loohp.interactivechat.objectholders.CustomPlaceholder)4 ClickEventAction (com.loohp.interactivechat.objectholders.CustomPlaceholder.ClickEventAction)4 CustomPlaceholderClickEvent (com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderClickEvent)4 CustomPlaceholderHoverEvent (com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderHoverEvent)4 CustomPlaceholderReplaceText (com.loohp.interactivechat.objectholders.CustomPlaceholder.CustomPlaceholderReplaceText)4 ParsePlayer (com.loohp.interactivechat.objectholders.CustomPlaceholder.ParsePlayer)4 ICPlaceholder (com.loohp.interactivechat.objectholders.ICPlaceholder)4 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)3 ByteStreams (com.google.common.io.ByteStreams)3 InteractiveChat (com.loohp.interactivechat.InteractiveChat)3 DataTypeIO (com.loohp.interactivechat.utils.DataTypeIO)3 List (java.util.List)3 Pattern (java.util.regex.Pattern)3 Collectors (java.util.stream.Collectors)3 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 Config (com.loohp.interactivechat.config.Config)2 ChatColorUtils (com.loohp.interactivechat.utils.ChatColorUtils)2 File (java.io.File)2 IOException (java.io.IOException)2