Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-3718

"java.lang.IllegalArgumentException: Component loop" when sending message which extends TextComponent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • Linux/CentOS 7

    • Custom

      I want to extend TextComponent to add my own features but for some reason this is causing an exception to be thrown.

       

      See the following plugin. When a player issues "/test", the plugin will attempt to send a message to the first player returned by Bukkit.getOnlinePlayers() using ChatComponent which extends TextComponent. This will kick the player and report the following error to the console: "java.lang.IllegalArgumentException: Component loop".

       

      Plugin source:

       

      package com.codespunk.testplugin;
      
      import java.util.LinkedList;
      import java.util.List;
      
      import org.bukkit.Bukkit;
      import org.bukkit.command.Command;
      import org.bukkit.command.CommandExecutor;
      import org.bukkit.command.CommandSender;
      import org.bukkit.entity.Player;
      import org.bukkit.plugin.java.JavaPlugin;
      import org.eclipse.jdt.annotation.NonNullByDefault;
      
      import net.md_5.bungee.api.chat.TextComponent;
      
      public class BukkitPlugin extends JavaPlugin implements CommandExecutor {
         public static class ChatComponent extends TextComponent {
            public ChatComponent(
               String text)
            {
               super(text);
            }
         }
      
         @Override
         public void onEnable() {
            getCommand("test").setExecutor(this);
         }
         
         @Override
         public boolean onCommand(CommandSender sender, Command command,
            String label, String[] args)
         {
            List<Player> players = new LinkedList<>(Bukkit.getOnlinePlayers());
            
            if (!players.isEmpty())
               players.iterator().next().spigot()
                  .sendMessage(new ChatComponent("Hello!"));
            
            return true;
         }
      }
      

            Unassigned Unassigned
            Zhro Matt D.
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: