I was making a confirmation Text Component with Bungee Chat ClickEvent for my plugin, the only way to send it to the player that worked for me was using player.sendMessage("" + message)
without throwing any error. But if I try to show the text in Minecraft, it happens this.
My full class code is:
package plugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
public class InfoCommand implements CommandExecutor {
public TextComponent TextComponent;
@Override
public boolean onCommand(CommandSender sender, Command cmnd, String alias, String[] args) {
if (!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
player.sendMessage("Some confirmation text.");
TextComponent yes = new TextComponent("Yes");
yes.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp info"));
player.sendMessage("[ " + yes + " ]");
return true;
}
}
What's the cause of that and how can I solve it?
It isn't any error. Is simply that we need to use the BungeeChat API and also the Spigot API (Not the Bukkit API).
For future reference, to solve the problem, we only need to follow this steps:
Download the Spigot API for your plugin version here (or add the Spigot API to your pom.xml if you are using Maven)
In your IDE, create a new library and assign your Spigot jar. After that, add the library to your project.
Make sure that Bukkit is propertly imported (import org.bukkit.*whatever*;
)
That should solve the problem.