[JAVA] How to display hover text and text that can be executed by clicking with Minecraft plugin

// Function to set hover text and click command in Minecraft chat // [Example 1] sendHoverText (player, "click here", null, "/ say good morning"); // [Example 2] sendHoverText (player, "Hover over", "Help message", null); // [Example 3] sendHoverText (player, "place the cursor and click", "help message", "/ say good morning"); public static void sendHoverText(Player p,String text,String hoverText,String command){ ////////////////////////////////////////// // Create hover text and events HoverEvent hoverEvent = null; if(hoverText != null){ BaseComponent[] hover = new ComponentBuilder(hoverText).create(); hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover); }

    //////////////////////////////////////////

// Create a click event ClickEvent clickEvent = null; if(command != null){ clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND,command); }

    BaseComponent[] message = new ComponentBuilder(text).event(hoverEvent).event(clickEvent). create();
    p.spigot().sendMessage(message);
}

Recommended Posts

How to display hover text and text that can be executed by clicking with Minecraft plugin
How to install a Python library that can be used by pharmaceutical companies
How to create a property of relations that can be prefetch_related by specific conditions
I made a plug-in that can "Daruma-san fell" with Minecraft
I bought and analyzed the year-end jumbo lottery with Python that can be executed in Colaboratory
Comparison of 4 styles that can be passed to seaborn with set_context
How to make a rock-paper-scissors bot that can be easily moved (commentary)
Draw a graph that can be moved around with HoloViews and Bokeh
I tried to make it on / off by setting "Create a plug-in that highlights double-byte space with Sublime Text 2".
[python] How to display list elements side by side
File types that can be used with Go
List packages that can be updated with pip
How to display images continuously with matplotlib Note
[Linux] How to display CPU usage, display header, and not display grep process with ps command
How to create a USB that Linux and Win10 installer and winpe can boot UEFI
How to filter foreign keys that can be selected on the Django admin screen
[Python] Introduction to web scraping | Summary of methods that can be used with webdriver
Morphological analysis and tfidf (with test code) that can be done in about 1 minute
Notes on how to use StatsModels that can use linear regression and GLM in python
The story that sendmail that can be executed in the terminal did not work with cron