command not working :/

Discussion in 'Spigot Plugin Help' started by liwaa, Jun 27, 2015.

  1. i am currently making a plugin and i got some problems:
    i made the first command and it worked; but the other 2 commands wont work
    and there are no error so please help me
    Code (Text):
    package me.liwaa.mm;


    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;

    public class commands extends JavaPlugin{
        @Override
        public void onEnable(){
            getConfig().options().copyDefaults(true);
            saveConfig();
            getLogger().info("Plugin mm enabled");
            new PlayerListener(this);
        }
     
        @Override  
        public void onDisable() {
         
        }
        public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args){
    //this is the working command
                if (cmd.getName().equalsIgnoreCase("mmp")){
                String p4p = getConfig().getString("permission to view permissions");
                if (sender.hasPermission(p4p)){
                String pex2 = getConfig().getString("Permission so that players cant enter the server");
                String pex3 = getConfig().getString("mm perm");
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3MaintainceMode&c=-=-=-=-=-=-=-="));
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3Permissions&c=-=-=-=-=-=-=-="));
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6permission so players cant enter the server: &f" + pex2 ));
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6permission to view permissions: &f" + p4p));
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6permission to do /mm: &f" + pex3));
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3Permissions&c=-=-=-=-=-=-=-="));
                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3MaintainceMode&c=-=-=-=-=-=-=-="));
    //this is not workigg
                }else if (cmd.getName().equalsIgnoreCase("mm")){
                    String pex3 = getConfig().getString("mm perm");
                    if (sender.hasPermission(pex3)){
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3MaintainceMode&c=-=-=-=-=-=-=-="));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3Help&c=-=-=-=-=-=-=-="));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4MM&8] &b/mm help for MaintainceMode"));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4MM&8] &b/mmp permissions for MaintainceMode"));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4MM&8] &b/mme do your job, gives the players the permission so they cant enter the server"));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3Help&c=-=-=-=-=-=-=-="));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3MaintainceMode&c=-=-=-=-=-=-=-="));
    //this is not working also
                    }
                    }else if(cmd.getName().equalsIgnoreCase("mme")){
                    String mme = getConfig().getString("command on mme");
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), mme);
                    sender.sendMessage("success");
                    return true;
                }
             
            }
             
         
     
            return false;
     
    }

    }
     
    thanks for your time
     
  2. please anyone
     
  3. 1- Wrong section
    2- There is no quoted text in sender.hasPermission(pex3) change it to:
    Code (Text):
    if (sender.hasPermission("pex.3")){
    3- Don't use "else if" when the command is different , change it to:
    Code (Text):
                 if (cmd.getName().equalsIgnoreCase("mm")){
                    String pex3 = getConfig().getString("mm perm");
                    if (sender.hasPermission("pex3")){
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3MaintainceMode&c=-=-=-=-=-=-=-="));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3Help&c=-=-=-=-=-=-=-="));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4MM&8] &b/mm help for MaintainceMode"));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4MM&8] &b/mmp permissions for MaintainceMode"));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4MM&8] &b/mme do your job, gives the players the permission so they cant enter the server"));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3Help&c=-=-=-=-=-=-=-="));
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c=-=-=-=-=-=-=-=&3MaintainceMode&c=-=-=-=-=-=-=-="));
                    }
                    if (cmd.getName().equalsIgnoreCase("mme")){
                    String mme = getConfig().getString("command on mme");
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), mme);
                    sender.sendMessage("success");
                    return true;
                }
     
  4. if other not just if