Chat Menus!

Discussion in 'Resources' started by Ad237, Feb 26, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Ad237

    Hi guys. I created this small class that can easily create a menu in chat similar to bukkit's /help command and I decided to share it. You can set the amount of entries to display per page and the color and display name of the menu. You can add an unlimited amount of entries and display a page to the player easily.

    You can download the code here: https://gist.github.com/Ad237/9236820

    An example using this is here:
    Code:java
    1. HelpMenu menu = new HelpMenu(ChatColor.DARK_AQUA + "Commands!", 9, ChatColor.GREEN);
    2. for(int x=0; x < 25; x++) {
    3. menu.addEntry("Entry: " + x);
    4. }
    5. menu.showPage(event.getPlayer(), 1);


    I would appreciate some credit if you do use this however it is not required.
     
    nelson2tm likes this.
  2. Offline

    CrazyGuy3000

    Skyost likes this.
  3. Offline

    Ad237

  4. Offline

    CrazyGuy3000

    Thanks :)
     
  5. Offline

    Scizzr

    Nothing too fancy, just a quick way to add an organized text menu.

    [​IMG]

    Here's the code I used for testing. You'd obviously want to store the menu and save it for later use (to save having to make the menu for each time the command is called)
    Code:
            if (args.length == 2 && args[0].equals("help") && MathUtils.isInt(args[1])) {
                try {
                    HelpMenu hm = new HelpMenu("Help Menu", 5, ChatColor.GREEN);
                    hm.addEntry("§aHere's the rules:");
                    hm.addEntry("§e1. §7Always follow rule #3.");
                    hm.addEntry("§e2. §7If in doubt, check rule #5");
                    hm.addEntry("§e3. §7When playing, obey rule #4");
                    hm.addEntry("§e4. §7Don't break rule #1!");
                    hm.addEntry("§e5. §7Please listen to rule #2.");
                    hm.showPage(player, Integer.valueOf(args[1]));
                } catch (Exception ex) {
                    player.sendMessage("§cUnable to show the help menu.");
                }
                return;
            }
    
     
    nelson2tm and Phasesaber like this.
  6. Offline

    Favorlock

    Very well done. Looks great. :)
     
Thread Status:
Not open for further replies.

Share This Page