Plugin list?!?

Discussion in 'Plugin Development' started by bwfcwalshy, Jul 22, 2014.

Thread Status:
Not open for further replies.
  1. So i have this code currently that blocks people from seeing plugins if they don't have a permission but how would i show them the plugin list?

    Current code:
    Code:java
    1. package com.bwfcwalshy.plmsg;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8.  
    9. public class Plugin implements CommandExecutor {
    10.  
    11. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    12. Player player = (Player) sender;
    13. if(cmd.getName().equalsIgnoreCase("plugin") || cmd.getName().equalsIgnoreCase("plugins") || cmd.getName().equalsIgnoreCase("pl") || cmd.getName().equalsIgnoreCase("version")){]
    14. if(sender.hasPermission("plmsg.view")){
    15. //Show plugins here
    16. }else{
    17. player.sendMessage(Main.pl.getConfig().getString("Message").replaceAll("&", "ยง"));
    18. }
    19. }
    20. return false;
    21. }
    22. }
    23.  
     
  2. Offline

    AGC-Intra

  3. AGC-Intra Its a String[] sendMessage only takes a String i know there's a way to do it but i can't remember.
     
  4. Offline

    Giraffeknee

    bwfcwalshy
    Why not just register one command and add aliases instead of checking for like 5 commands?
    Also just loop through the strings in the String[] and send them to the player.
     
  5. Offline

    CorrieKay

    Bukkit.getPluginManager().getPlugins() returns a Plugin array, not a string array. You're going to want to iterate over the array using a for loop, and possibly use a string builder.

    Code:java
    1. StringBuilder sb = new StringBuilder();
    2. for(Plugin plugin : Bukkit.getPluginManager().getPlugins()){
    3. sb.append(plugin.getName() + ", ");
    4. }
    5. sender.sendMessage(sb.substring(0, sb.length() - 2));
     
    AGC-Intra likes this.
  6. Offline

    Necrodoom

    Seems like a duplication of the existing bukkit.command.plugins node, though.
     
Thread Status:
Not open for further replies.

Share This Page