[BUILDTOOLS-369] "java.lang.IllegalArgumentException: Component loop" when sending message which extends TextComponent Created: 25/Dec/17 Updated: 26/Dec/17 Resolved: 26/Dec/17 |
|
Status: | Resolved |
Project: | BuildTools |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Matt D. | Assignee: | Unassigned |
Resolution: | Invalid | Votes: | 0 |
Labels: | TextComponent | ||
Environment: |
Linux/CentOS 7 |
Plugin: | Custom |
Description |
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; } }
|
Comments |
Comment by Matt D. [ 25/Dec/17 ] |
This was submitted to the wrong project. See here for the correct report:
|