Examples of use
This page show examples of uses of the EasyComponent library.
Example 1 - Simple TextComponent
TextComponent component = new EasyComponent()
.setText("Hey ! Hover me to see a message !")
.showText("&bHello !")
.setColor(ChatColor.AQUA)
.getAsTextComponent();
Result

Example 2 - Run a command
TextComponent component = new EasyComponent()
.setText("Hey ! Click on me to say something.")
.showText("&bClick !")
.setColor(ChatColor.AQUA)
.runCommand("say Hey !")
.getAsTextComponent();
Result

Example 3 - Suggest a command
TextComponent component = new EasyComponent()
.setText("Hey ! Click to say something.")
.showText("&bClick !")
.setColor(ChatColor.AQUA)
.suggestCommand("say Hey !")
.getAsTextComponent();
Result

Example 4 - Open an URL
TextComponent openURL = new EasyComponent()
.setText("[Click here]")
.showText("&eClick to open an url !")
.openUrl("https://www.spigotmc.org/")
.setColor(ChatColor.YELLOW)
.getAsTextComponent();
TextComponent component = new EasyComponent()
.setText("Hey ! Want to go on Spigot ? ")
.setColor(ChatColor.GOLD)
.addExtra(openURL)
.getAsTextComponent();
Result

Example 5 - Placeholder replacement
EasyComponent clickMe = new EasyComponent()
.setText("&2[&aClick here&2]")
.showText("&aClick !");
TextComponent component = new EasyComponent()
.setText("Hey ! %click% to say something.")
.setColor(ChatColor.AQUA)
.replace("%click%", clickMe)
.getAsTextComponent();
Result

Last updated
Was this helpful?