Skip to content

seasonguy/ChatMenuAPI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ChatMenuAPI

An API for making menus inside Minecraft's chat. This API treats Minecraft's chat like a 2D grid, allowing you to position elements freely in chat.

Preview


Contents


Usage

Setup

Add ChatMenuAPI.jar to your build path, then add it as a dependency in your plugin.yml:

depend: [ChatMenuAPI]

ChatMenu

To create a menu, just create a new instanceof ChatMenu:

ChatMenu menu = new ChatMenu();

If you are not using this API just for chat formatting, it is recommended that you make the menu a pausing menu:

ChatMenu menu = new ChatMenu().pauseChat();

When this menu is sent to a player, it will automatically pause outgoing chat to that player so that the menu will not be interrupted.

Warning: If you make a menu pause chat, you need to add a way to close the menu!

Element

Elements are the building blocks of menus. They are used to represent everything in a menu. There are a few elements provided by default, you can view them by clicking here.

Basic TextElement:

menu.addElement(new TextElement("Hello, world!", 10, 10));

Basic close button:

menu.addElement(new ButtonElement(x, y, ChatColor.RED+"[Close]", (p) -> {menu.close(p); return false;}));

States

Most interactive elements have one or more State objects.

States are used to store information about an Element, such as the current number in an IncrementalElement.

Every state can have a change callback to detect when it changes:

IncrementalElement incr = ...;
incr.value.onChange((s) -> {
	System.out.println("IncrementalElement changed! "+s.previous()+" -> "+s.current());
});

Displaying

Once you've created your menu and added all the elements you want, now would probably be a good time to display it. You can display a menu using ChatMenu#openFor(Player player):

Player p = ...;
menu.openFor(p);

Links

About

An API for making menus inside Minecraft's chat.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%