Solved Custom Plugin List

Discussion in 'Plugin Development' started by cosmicARTS, Aug 14, 2014.

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

    cosmicARTS

    Hi! I am making a server at the moment and I was wondering how I could make my plugin list (when I type /pl or /plugins) look like this:

    [​IMG]

    Thanks a lot! I have no idea how to do it, or if I even need code xD
     
  2. Offline

    TrollTaylor

    cosmicARTS Use PlayerCommandPreprocessEvent and see if they typed /plugins or /pl then change the message
     
  3. Offline

    Gerov

    cosmicARTS Of course you would need to code, you'd loop through all the server's plugins, and then message the player with:

    Code:java
    1. PLAYER_OBJECT.sendMessage(ChatColor.ORANGE+"TheZone"+ChatColor.AQUA+PLUGIN_OBJECT);


    Or you could do what TrollTaylor says, that'd be easier.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    kmecpp

    cosmicARTS You can use this as format:

    Code:
        @EventHandler
        public void onCommandPreprocess(PlayerCommandPreprocessEvent e){
            if(e.getMessage().equalsIgnoreCase("/pl") || e.getMessage().equalsIgnoreCase("/plugins")){
                e.setCancelled(true);
                e.getPlayer().sendMessage(ChatColor.GOLD + "TheZone" + ChatColor.GRAY + " →→ " + ChatColor.AQUA + "Plugin1");
                e.getPlayer().sendMessage(ChatColor.GOLD + "TheZone" + ChatColor.GRAY + " →→ " + ChatColor.AQUA + "Plugin2");
                e.getPlayer().sendMessage(ChatColor.GOLD + "TheZone" + ChatColor.GRAY + " →→ " + ChatColor.AQUA + "Plugin3");
                e.getPlayer().sendMessage(ChatColor.GOLD + "TheZone" + ChatColor.GRAY + " →→ " + ChatColor.AQUA + "Plugin4");
                e.getPlayer().sendMessage(ChatColor.GOLD + "TheZone" + ChatColor.GRAY + " →→ " + ChatColor.AQUA + "Plugin5");
            }
        }

    EDIT:

    If you want to include the plugin versions then do this,


    Code:
        @EventHandler
        public void onCommandPreprocess(PlayerCommandPreprocessEvent e){
            if(e.getMessage().equalsIgnoreCase("/pl") || e.getMessage().equalsIgnoreCase("/plugins")){   
                e.setCancelled(true);
                Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
                for(Plugin pl : plugins){
                    e.getPlayer().sendMessage(ChatColor.GOLD + "TheZone" + ChatColor.GRAY + " →→ " + ChatColor.AQUA + pl.getName() + ChatColor.GRAY + " v" + ChatColor.AQUA + pl.getDescription().getVersion());
                }
            }
        }
    Its also much more efficient and accurate than doing it the other way
     
  5. Offline

    cosmicARTS

    Thank you so much! I have never used a PlayerCommandPreprocessEvent, so I would have asked for an example! Thanks :) I'll let you know if it worked or not!

    kmecpp It works! Thanks so much!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page